# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-hkdf
_pkgname=hkdf
pkgver=1.0.4
pkgrel=0
pkgdesc="HMAC-based Extract-and-Expand Key Derivation Function (RFC 5869)"
url="https://github.com/hannesm/ocaml-hkdf"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-2-Clause"
depends="ocaml-runtime ocaml-cstruct ocaml-mirage-crypto"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-cstruct-dev ocaml-mirage-crypto-dev"
makedepends="$depends_dev dune ocaml"
checkdepends="ocaml-alcotest-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/hannesm/ocaml-hkdf/releases/download/v$pkgver/hkdf-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
d08e50857f7761572adc4d382975fde5808898c1d92d9e6e943a496cba8780ffabe1edf67844063b70d9727c0fe10b24391e001a3f65c978a5326ac82199cc88  ocaml-hkdf-1.0.4.tar.bz2
"
